package edu.washington.ling.syntric.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class RuleFileWriterText extends RuleFileWriter {

	private PrintStream pStream;
	
	public RuleFileWriterText(String path) throws IOException {
		super(path);
		try {
			pStream = new PrintStream(new FileOutputStream(new File(path)), true, "UTF8");
		} 
		catch(UnsupportedEncodingException e) {
			pStream = new PrintStream(new FileOutputStream(new File(path)), true);
		}
	}
	@Override
	public void close() {
		pStream.flush();
		pStream.close();
	}
	@Override
	public void writeRuleRep(RuleRepresentation rr, int count) {
		pStream.println(String.format("%d\t%s\t%s", count, rr.getDSPattStr(), rr.getPSPattStr()));
	}

}
